<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>

        var user = {
            name:"zhangsna",
            age:18,
            sex:"男"
        };

        //将对象转换为json字符串
        var jsonUser = JSON.stringify(user);

        //json字符串转换为对象
        var obj = JSON.parse('{"name":"zhangsna","age":18,"sex":"男"}')

    </script>


</head>
<body>

</body>
</html>